
var WindText = new Object();

WindText.createView = function() {
	var text = new WindView();
	text.setCssClass("WindText");
	
	text.setName = function(name) {
		this.name = name;
	}
	
	text.getName = function() {
		return this.name;
	}
	
	text.setLines = function(lines) {
		this.lines = lines;
	}
	
	text.setLines(1);

	text.getLines = function() {
		return this.lines;
	}
	
	text.isValid = function(value) {
		return true;
	}
	
	text.render = function() {
		var element = null;

		if(this.getLines()==1) {
			element = document.createElement("input");
			element.type = "text";
		} else {
			element = document.createElement("textarea");		
			element.rows = this.getLines();
		}

		text.setHtmlElement(element);
		
		element.onblur = function() {
			if(text.isValid(element.value)) {
				text.setValue(element.value);
			} else {
				element.value = "";
			}
		}		

		element.onchange = function() {
			if(text.isValid(element.value)) {
				text.setValue(element.value);
			} else {
				element.value = "";
			}
		}		
		
		if(text.getValue()!=null) {
			var value = text.getValue();
			if(text.getValueAsString!=null) {
				value = text.getValueAsString(value);
			}
			element.value = value;
		}
		
		this.applyViewAttributesToHtmlElement(element);
				
		return element;
	}
	
	return text;
}